package com.scy.hospitalmanager.service.impl;

import com.scy.hospitalmanager.dao.nursedao.NurseLoginDao;
import com.scy.hospitalmanager.pojo.NurseLogin;
import com.scy.hospitalmanager.service.NurseLoginService;
import com.scy.hospitalmanager.until.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 护士登陆实现
 * @ClassName: NurseLoginServiceImpl
 * @Author: KuonnjiArisu
 * @Date: 2021/8/17 9:26
 * @Version: 1.0
 */
@Service
public class NurseLoginServiceImpl implements NurseLoginService {
    @Autowired
    NurseLoginDao nurseLoginDao;
    @Override
    public NurseLogin loginByAccountAndByPassword(NurseLogin nurseLogin) {
        return nurseLoginDao.loginByAccountAndByPassword(nurseLogin) ;
    }

    @Override
    public Integer insertLogin(NurseLogin nurseLogin) {
        NurseLogin nurseLogin1 = this.getAllNurseLogin().get(this.getAllNurseLogin().size()-1);
        nurseLogin.setNlPassword(MD5.md5(nurseLogin.getNlPassword()));
        Long nlNurseId = nurseLogin1.getNlNurseId()+1;
        nurseLogin.setNlNurseId(nlNurseId);
        return nurseLoginDao.insertLogin(nurseLogin);
    }

    @Override
    public List<NurseLogin> getAllNurseLogin() {
        return nurseLoginDao.getAllNurseLogin();
    }

    @Override
    public Integer updateNurseLoginById(NurseLogin nurseLogin) {
        return nurseLoginDao.updateNurseLoginById(nurseLogin);
    }
}
